<template>
  <div class="u-p-20">
    <el-card shadow="never">
      <div slot="header">
        <span>
          <b class="u-f-16">商品统计列表</b>
        </span>
      </div>

      <el-form :inline="true" :model="queryForm" size="small" class="u-text-center">
        <el-form-item label="时间范围">
          <el-date-picker
            v-model="queryForm.timeStr"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd"
          ></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="getPageData()">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table @sort-change="changeSort"  ref="table" :data="tableData" class="u-mt-10" v-viewer>
        <el-table-column label="排序" type="index" :index="getIndexNo" width="100"></el-table-column>
        <el-table-column label="日期" prop="create_date_day"></el-table-column>
        <el-table-column label="销售额" prop="sell_price" sortable></el-table-column>
        <el-table-column label="盈利额" prop="gain_price" sortable></el-table-column>
        <el-table-column label="支付订单数" prop="pay_count"></el-table-column>
        <el-table-column label="取消订单数" prop="cancel_count"></el-table-column>
      </el-table>
      <div class="u-mt-20 u-text-center">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handlePageChange"
          :current-page="currentPage"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="limit"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div>
    </el-card>
  </div>
</template>

<script>
import commonPage from "@/mixins/common-page";
// import excel from '@/libs/excel'

export default {
  mixins: [commonPage],
  data() {
    return {
      apiName: "orderCensus",
      queryForm: {
        timeStr: "",
      },
    };
  },
  methods: {
    changeTimes(val) {
      this.changeTime = val;
      this.queryForm.timeStr = val;
      this.getPageData();
    },
    changeSort(val) {
      if (this.$refs.table) {
        this.$refs.table.clearSort();
      }
      this.queryForm.field = val.prop;
      let order = val.order;
      if (order == "ascending") {
        order = "asc";
      } else {
        order = "desc";
      }
      this.queryForm.order = order;
      let that = this;
      this.tableData = [];
      that.getPageData(true);
    },
  },
};
</script>
